<template>
    <Page>
        <Topbar hideMenu />
        <Content>
            <Panel header headerBorder title="返工执行" style="padding: 4rem;">
                <view slot="toolbar">
                    <view class="back" @click="back">
                        <u-icon name="arrow-left" color="#666" size="14" style="margin-right: 0.5rem;"></u-icon> 返回
                    </view>
                </view>
                <view class="table-demo">
                    <Table ref="table" :columns="columns" :src="src" :params="params" @rowClick="click" pagination />
                </view>
            </Panel>
        </Content>
    </Page>
</template>

<script>
    import Page from "@/components/page/index.vue";
    import Topbar from "@/components/topbar/index.vue";
    import Content from "@/components/content/index.vue";
    import Panel from "@/components/panel/index.vue";
    import Table from '@/components/table/index.vue';
    import {
        getDevice
    } from "@/store/user.js";
    import fetch from "@/utils/fetch.js";

    export default {
        components: {
            Page,
            Topbar,
            Content,
            Panel,
            Table
        },
        data() {
            return {
                src: '/dms/mobileEnd/getReworkPadList',
                params: {
                    equipmentNumber: getDevice().deviceNo
                },
                columns: [{
                    label: '返工单号',
                    value: 'applicationNumber',
					width:'20rem',
                }, {
                    label: '状态',
                    value: 'reworkStatus',
                }, {
                    label: '工序',
                    value: 'productionProcesses',
                }, {
                    label: '工单号',
                    value: 'workOrder',
					width:'20rem',
                }, {
                    label: '产品编号',
                    value: 'materialCode',
					width:'20rem',
                }, {
                    label: '产品名称',
                    value: 'materialName',
                    width:'43rem',
                }, {
                    label: '产品型号',
                    value: 'materialModel',
					width:'37rem',
                }, {
                    label: '发起人',
                    value: 'initiator',
                }, {
                    label: '发起数量',
                    value: 'initiationsNumber',
                    type: 'number'
                }, {
                    label: '发起时间',
                    value: 'reworkStartTime',
					width:'32rem',
                }],
            }
        },
        methods: {
            back() {
                this.goto('/pages/workbench/index');
            },
            goto(url) {
                uni.navigateTo({
                    url,
                    animationType: "pop-in",
                    animationDuration: 1000,
                })
            },
            click(item) {
                this.goto('/pages/workbench/rework/form/index?applicationNumber=' + item.applicationNumber);
            },
        },
        mounted() {
            this.$refs['table'] && this.$refs['table'].reload();
        },
        onShow() {
            this.$refs['table'] && this.$refs['table'].reload();
        }
    }
</script>

<style scoped lang="scss">
    .back {
        display: flex;
        justify-content: center;
        align-items: center;
        color: #666;
    }

    .table-demo {
        flex: 1;
        display: flex;
        flex-direction: column;
    }
</style>